<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <!-- Bootstrap -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
          integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

</head>
<body>
<div class="container">
    <form role="form" id="ddd" class="form-horizontal">
        <div class="form-group">
            <label for="" class="col-sm-2 control-label">姓名</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" name="username">
            </div>
        </div>
        <div class="form-group">
            <label for="" class="col-sm-2 control-label">密码</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" name="password">
            </div>
        </div>
        <div class="form-group">
            <label for="" class="col-sm-2 control-label">昵称</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" name="nick">
            </div>
        </div>
        <div class="form-group">
            <input class="btn btn-primary center-block" type="button" value="注册" @click="reg()">
        </div>
    </form>
</div>
<!--引入axios框架-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<!--引入vue框架-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    let v = new Vue({
        el: "form",
        data: {},
        methods: {
            reg: function () {
                let data = new FormData(document.querySelector("form"));
                axios.post("/reg", data).then(function (response) {

                    if (response.data == 1) {
                        location.href = "/";
                    } else {
                        alert("注册失败!")
                    }

                })
            }
        }
    })
</script>
</body>
</html>